{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}

{% set modal_class = 'modal-lg' %}

{% block title %}
  {% if tagGroup.name|default(null) %}{{'编辑标签组'|trans}}{% else %}{{'添加标签组'|trans}}{% endif %}
{% endblock %}
{% block body %}
  <form class="form-horizontal" id="tag-group-form" action="{% if tagGroup.name|default(null) %}{{ path('admin_tag_group_update',{groupId:tagGroup.id|default(null)}) }}{% else %}{{ path('admin_tag_group_create') }}{% endif %}" method="post">
    <div class="form-group">
      <label class="col-md-3 control-label" for="tag-group-name-field">{{'标签组名称'|trans}}</label>
      <div class="col-md-8 controls">
        <input class="form-control" id="tag-group-name-field" type="text" name="name" value="{{ tagGroup.name|default(null) }}" data-url="{{ path('admin_tag_group_checkname', {exclude:tagGroup.name|default(null)}) }}">
      </div>
    </div>

    <div class="form-group">
      <label class="col-md-3 control-label">{{'用于'|trans}}</label>
      <div class="col-md-6 controls" style="padding-top: 7px;">
      <label class="required"><input type="checkbox" data-role="batch-select" name="scope[]" value="course" {% if 'course' in tagGroup.scope|default('') %}checked="checked"{% endif %}>课程列表筛选</label>
      
      <label class="required"><input type="checkbox" data-role="batch-select" name="scope[]" value="classroom" {% if 'classroom' in tagGroup.scope|default('') %}checked="checked"{% endif %}>
        班级列表筛选</label>
      </div>
    </div>
  
    <div class="form-group">
      <label class="col-md-3 control-label">包含标签</label>
      <div class="col-md-8 controls">
        <input class="form-control" id="tags" type="text" name="tags" value="{{ tags|default('')|join(',') }}" data-url="{{ path('tag_match') }}">
        <div class="help-block">
          回车可添加标签，标签组内添加的标签也会添加到标签管理中
        </div>
      </div>
    </div>

    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
  </form>
  <script type="text/javascript">app.load('tag-group/save-modal')</script>
{% endblock %}

{% block footer %}
  {% if tagGroup.name|default(null) %}
    <button class="btn btn-default pull-left delete-tag-group" data-url="{{ path('admin_tag_group_delete', {tagId:tagGroup.id}) }}" data-target="{{ tagGroup.id }}" data-tag-group-id="{{ tagGroup.id }}"><i class="glyphicon glyphicon-trash"></i> {{'删除'|trans}}</button>
  {% endif %}

  <button type="button" class="btn btn-link" data-dismiss="modal">{{'取消'|trans}}</button>
  <button id="tag-group-create-btn" data-submiting-text="{{'正在提交'|trans}}" type="submit" class="btn btn-primary" data-toggle="form-submit" data-target="#tag-group-form">{{'保存'|trans}}</button>
{% endblock %}
